﻿using System;

namespace SXICE.Core.Infrastructure
{
    /// <summary>
    /// 分布式缓存
    /// </summary>
    public interface IDistributedCache : ICacheBase
    {
        /// <summary>
        /// 订阅事件
        /// </summary>
        /// <param name="channel">频道</param>
        /// <param name="action">回调函数</param>
        void Subscribe(string channel, Action<string, string> action);

        /// <summary>
        /// 发布事件
        /// </summary>
        /// <param name="channel">频道</param>
        /// <param name="value">内容</param>
        void Publish(string channel, string value);

        /// <summary>
        /// 获得分布式锁
        /// </summary>
        /// <param name="key">Key</param>
        /// <param name="expire">超时时间</param>
        bool AcquireLock(string key, TimeSpan expire);

        /// <summary>
        /// 释放分布式锁
        /// </summary>
        /// <param name="key">key</param>
        /// <returns>结果</returns>
        bool ReleaseLock(string key);
    }
}
